from django.http import HttpResponse
from django.shortcuts import render
from blog.models import Check_info
# Create your views here.


def index(request):
    return render(request,'index.html')


def show_qr(request):
    name = request.GET.get('name')
    uid = request.GET.get('uid')
    context = {
        'name':name,
        'uid':uid,
        'url':f'http://127.0.0.1:8000/check_info?name={name}&uid={uid}',
    }

    return render(request,'qr_code.html',context=context)


def check_info(request):
    name = request.GET.get('name')
    uid = request.GET.get('uid')
    check_info1 = Check_info.objects.create(name=name,uid=uid)
    check_info1.save()
    message =f'用户{name}-{uid}签到成功'
    return HttpResponse(message)